/*
 * CS_MATCH_USER_INFO.cpp
 *
 *  Created on: 2013. 9. 25.
 *      Author: mega@gamevil.com
 */

#include "../../User.h"
#include "../../NLogic/Static.h"
#include "../../NLogic/Battle.h"
#include "../../NLogic/Function.h"
#include "matching.h"

namespace ProjectZ { namespace NCommand { namespace NMatching {

void CS_MATCH_USER_INFO::OnExecute(User * pUser, ::Network::Packet * pPacket)
{
/*
	대전 상대정보 요청 C->S
	CS_MATCH_USER_INFO		0x0607
	{
		u32		u32GID;			//상대 GID
	}
*/

	PREPARE_PACKET;

	int oppUserSeq	= 0;

	*pPacket >> oppUserSeq;

	DEBUGLOG("	##### CS_MATCH_USER_INFO : MySeq=%d, OppSeq=%d", pUser->GetUserSeq(), oppUserSeq);

	NLogic::Space * pSpace	= pUser->GetSpace();
	if (pSpace == NULL)
	{
		DEBUGLOG("CS_MATCH_USER_INFO : pSpace is NULL!!");
		return;
	}

	User * pOppUser = NULL;

	if (pSpace->GetData()._spaceType == NLogic::Space::SpaceType::PVP_USER
			|| pSpace->GetData()._spaceType == NLogic::Space::SpaceType::NEW_PVP_ROOM)
	{
		pOppUser = pUser->GetBattle()->GetData()._pvpOppUser;
	}
	else
	{
		pOppUser = pSpace->FindUser(oppUserSeq);
	}

//	const NLogic::Static::SPACETREE & worldTree = NLogic::Static::InstancePtr()->GETWORLDSPACETREE();
//	NLogic::Static::SPACETREE::const_iterator citer = worldTree.begin();
//
//	for ( ; citer != worldTree.end(); citer++)
//	{
//		pOppUser = citer->second->FindUser(userSeq);
//		if (pOppUser != NULL)
//			break;
//	}

	if (pOppUser == NULL)
	{
		DEBUGLOG("CS_MATCH_USER_INFO : pOppUser is NULL!!");
		return;
	}

	NLogic::NFunction::SendCharacterDefaultInfo(pOppUser, pUser);
//	::ProjectZ::NGame::SendCharacterFairyInfo(pOppUser, pUser);
	NLogic::NFunction::SendCharacterEquipInfo(pOppUser, pUser);
}

} /*NMatching*/ } /*NCommand*/ } /*ProjectZ*/
